/*
 * @Descripttion: GGB
 * @version: 1.0
 * @Author: GGB
 * @Date: 2021-08-20 20:51:47
 * @LastEditors: GGB
 * @LastEditTime: 2021-08-20 22:09:02
 */
import 'package:flutter/material.dart';
import 'package:flutter_data_center/controller/school_attendance_controller.dart';
import 'package:flutter_data_center/utills/color_utils.dart';
import 'package:get/get.dart';

class GradeMenu extends StatelessWidget {
  const GradeMenu({Key key, this.currentIndex, this.onTap}) : super(key: key);
  final int currentIndex;
  final ValueChanged<int> onTap;

  @override
  Widget build(BuildContext context) => GetBuilder<SchoolAttendanceController>(
        builder: (_controller) => Container(
          height: 30,
          width: double.infinity,
          child: Row(
            children: [
              Container(child: Text("年级")),
              Expanded(
                child: ListView.builder(
                  scrollDirection: Axis.horizontal,
                  itemCount: _controller.menus.length,
                  itemBuilder: (context, index) => GestureDetector(
                    onTap: () => onTap(index),
                    child: Row(
                      children: [
                        SizedBox(width: 10),
                        Container(
                          height: 20,
                          alignment: Alignment.center,
                          padding: EdgeInsets.symmetric(horizontal: 10),
                          decoration: BoxDecoration(
                            borderRadius: BorderRadius.circular(10),
                            color: currentIndex == index
                                ? Theme.of(context).primaryColor
                                : Colors.transparent,
                          ),
                          child: Text(
                            _controller.menus[index].value,
                            style: TextStyle(
                              fontSize: 14,
                              height: 1,
                              color: currentIndex == index
                                  ? Colors.white
                                  : gColor("#ABABAB"),
                            ),
                          ),
                        ),
                      ],
                    ),
                  ),
                ),
              ),
            ],
          ),
        ),
      );
}
